package com.example.hydropowermanage.service.lmpl;

import com.example.hydropowermanage.mapper.LoginMapper;
import com.example.hydropowermanage.pojo.User123;
import com.example.hydropowermanage.service.LoginService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户管理（登录）
 *
 * @author yxy
 */
@Service
public class LoginServicelmpl implements LoginService {

    @Autowired
    private LoginMapper loginMapper;

    @Override
    public List<User123> selectList(User123 user123) {
        return loginMapper.selectList(user123);
    }
    // 返回所有的用户信息
    public List<User123> getAllUsers() {
        return loginMapper.selectAllUser();
    }

    @Override
    public User123 findID(@Param("id") int id) {
        return loginMapper.findID(id);
    }

    @Override
    public int insertUser(User123 user123) {
        return loginMapper.insertUser(user123);
    }

    @Override
    public Boolean checkUserUnique(User123 user123) {
        int id = user123.getId()==0?-1:user123.getId();
        User123 info = loginMapper.checkUserUnique(user123);
        if(info!=null&&info.getId()!=id){
            return true;
        }
        return false;
    }

    @Override
    public int updateUser(User123 user123) {
        return loginMapper.updateUser(user123);
    }

    @Override
    public int deleteUser(String id) {
        return loginMapper.deleteUser(id);
    }
}
